# -*- coding: utf-8 -*-

from w.blocks.containers.block import Block

from w.html.doctypes.preferable import Textarea

class EditBox(Block):
    def __init__(self, content=None, cols=64, rows=8, wrap='soft', *argv, **kwargv):
        if isinstance(content, list):
            raise ValueError("Content can't be a list")

	content = content.replace('\r\n', '\n')
	content = content.replace('\n', '\\n')
        Block.__init__(self, content)

        self.cols = cols
        self.rows = rows
        self.wrap = wrap
        self.tag = Textarea(*argv, **kwargv)
        self.html = self.tag.html

    def make(self, content=[]):
        if not content:
            content = self
        if content:
            content = content[0]
            self.tag.append(content)

        self.tag.html.cols = self.cols
        self.tag.html.rows = self.rows
        self.tag.html.wrap = self.wrap
        return Block.make(self, [self.tag,])

